package com.zq.quartz;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;
@DisallowConcurrentExecution
public class NoticeJob implements Job {
    private static int a=0;
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println("执行消息定时任务开始---"+a+new Date());
        a++;


        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if(a==5){
            System.out.println("修改时间");
            QuartzManager.modifyJobTime("JobName", "JobGroupName", "syncJobTrigger", "sycJobGroup", "0/3 * * * * ?");
        }

        if(a==10){
            System.out.println("结束任务");
            QuartzManager.removeJob("JobName", "JobGroupName", "syncJobTrigger", "sycJobGroup");
        }
        System.out.println("执行消息定时任务结束---"+a+new Date());


    }

}

